#include "maximumBags.h"
int maximumBags(std::vector<int> &capacity, std::vector<int> &rocks,
                int additionalRocks) {
    int n = capacity.size();
    std::vector<int> diff = std::vector<int>(n, 0);
    for (int i = 0; i < n; i++) {
        diff[i] = capacity[i] - rocks[i];
    }
    std::sort(diff.begin(), diff.end());
    int num = 0;
    for (int i = 0; i < n; i++) {
        if (diff[i] <= additionalRocks) {
            num++;
            additionalRocks -= diff[i];
        } else
            break;
    }
    return num;
}
